__author__ = 'channiewu'

from flask import Flask
from flask.ext.sqlalchemy import SQLAlchemy
from inqueue import db
from inqueue.models import User
from inqueue.models import Food
from inqueue.models import Truck
import datetime

db.create_all()

def insertUser(name, username, email, phone, carrier):
    new_user = User(name=name,
                  username=username,
                  email=email,
                  phone=phone,
                  carrier=carrier)
    db.session.add(new_user)
    db.session.commit()

    all_users = User.query.all()
    print('current users are: ')
    for user in all_users:
        print user

def clearAllUsers():
    all_users = User.query.all()
    for user in all_users:
        db.session.delete(user)
        db.session.commit()

def insertFood(name, description):
    new_food = Food(name=name,
                    description=description)
    db.session.add(new_food)
    db.session.commit()

    all_food = Food.query.all()
    print('current food items: ')
    for food in all_food:
        print food

def insertTruck(name, category, description):
    new_truck = Truck(name=name,
                      category=category,
                      description=description)
    db.session.add(new_truck)
    db.session.commit()

    all_truck = Truck.query.all()
    print('our trucks: ')
    for truck in all_truck:
        print truck

def insertMenuItem(truck_name, date, food_name, food_desc, max_quantity):
    truck = db.session.query(Truck).filter_by(name=truck_name).value('id')
    print truck
    d = datetime.date(2003, 7, 29)
    print d


clearAllUsers()
insertUser('Channie', 'channie','cwu@linkedin.com', '3010838394', 'Spring')

insertFood('Chicken Sandwich', 'Sandwich with fried chicken.')

insertTruck('Eat on Monday', 'American', 'We serve sandwiches.')

#insertMenuItem('Eat on Monday', '08042012', '', '', 3)